package com.aliengen.thingple.thingple.fillingstation;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.aliengen.thingple.thingple.AbstractThingpleActivity;
import com.aliengen.thingple.thingple.R;
import com.aliengen.thingple.thingple.maintenance.CylinderMaintenanceActivity;
import com.aliengen.thingple.thingple.tag.CylinderTag;

/**
 * This class is part of the Thingple mobile application for the CMC168 Handheld reader.
 *
 * Copyright AlienGen Limited 2016. All rights reserved.
 *
 * @author Timothé Mermet-Buffet <tim@aliengen.com>
 */
public class CylinderActivity extends AbstractThingpleActivity {

    protected CylinderTag cylinder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cylinder);
        setOperatorName();

        this.cylinder = (CylinderTag) getIntent().getExtras().get("cylinder_tag");

        setText(R.id.cylinderReference, R.string.cylinder_reference, this.cylinder.getReference());
        setText(R.id.cylinderGasType, R.string.cylinder_gas_type, this.cylinder.getGasType());
        setText(R.id.cylinderPressure, R.string.cylinder_pressure, this.cylinder.getPressure());
        setText(R.id.cylinderStatus, R.string.cylinder_status, this.cylinder.getStatus());
        setText(R.id.cylinderState, R.string.cylinder_state, this.cylinder.getLastOperation());
        setText(R.id.cylinderMaintenance, R.string.cylinder_next_maintenance, this.cylinder.getNextMaintenance());

        setText(R.id.cylinderBundleId, R.string.cylinder_bundle, ""+this.cylinder.getCylinder().bundleId);
        //setText(R.id.cylinderTagStatus, R.string.cylinder_tag_status, ""+this.cylinder.getCylinder().tagStatus);
        //setText(R.id.cylinderFacilityCode, R.string.cylinder_facility_code, ""+this.cylinder.getCylinder().facilityCode);
        setText(R.id.cylinderMonth, R.string.cylinder_month, ""+this.cylinder.getCylinder().month);
        setText(R.id.cylinderDay, R.string.cylinder_day, ""+this.cylinder.getCylinder().day);
        setText(R.id.cylinderProduct, R.string.cylinder_product, ""+this.cylinder.getCylinder().productId);

        //setText(R.id.cylinderAnomaly, R.string.cylinder_anomaly, this.cylinder.getAnomalyName());
        //setText(R.id.cylinderAnomalyStep, R.string.cylinder_anomaly_step, this.cylinder.getAnomalyStep());

    }

    public void onClickMaintenance(View view){
        Intent nextScreen = new Intent(getApplicationContext(), CylinderMaintenanceActivity.class);
        nextScreen.putExtra("cylinder_tag", this.cylinder);
        startActivity(nextScreen);

        //showToast("Not yet implemented!");
        this.finish();
    }

    public void onClickSearch(View view){
        Intent nextScreen = new Intent(getApplicationContext(), SearchActivity.class);
        nextScreen.putExtra("cylinder_tag", this.cylinder);
        startActivity(nextScreen);
    }

    public void onClickAnomaly(View view){
        Intent nextScreen = new Intent(getApplicationContext(), AnomalyActivity.class);
        nextScreen.putExtra("cylinder_tag", this.cylinder);
        startActivity(nextScreen);
        this.finish();
    }

    public void onClickBack(View view){
        this.finish();
    }
}
